package p2polymorphism;

class A{
	public void print1(){
		System.out.println(" public method A.print1" );
	}
	public void print2(){
		printPrivate();
	}
	private void printPrivate(){
		System.out.println(" private method A.printPrivate" );
	}
	public final void printFinal(){
		System.out.println(" public final method A.printFinal" );
	}
	public static void print3(){
		System.out.println(" public static method A.print3" );
	}
}

class B extends A{
	public void print1(){
		System.out.println(" public method B.print1" );
	}	
	private void printPrivate(){
		System.out.println(" private method B.printPrivate" );
	}
	public static void print3(){
		System.out.println(" public static method B.print3" );
	}
}

public class Polymorphism {

	public static void main(String[] args) {
		System.out.println("------ A a ------");
		A a = new A();
		if (a instanceof A)
			System.out.println("a is-an A");
		if (a instanceof B)
			System.out.println("a is-a B");			
		a.print1();
		a.print2();
		a.print3();
		a.printFinal();

		System.out.println("\n\n------ A b ------");
		A b = new B();
		if (b instanceof A)
			System.out.println("b is-an A");
		if (b instanceof B)
			System.out.println("b is-a B");			
		b.print1();
		b.print2();
		b.print3();
		b.printFinal();

		System.out.println("\n\n------ B bb ------");
		B bb = new B();
		if (bb instanceof A)
			System.out.println("bb is-an A");
		if (bb instanceof B)
			System.out.println("bb is-a B");			
		bb.print1();
		bb.print2();
		bb.print3();
		bb.printFinal();

	}
}
